//#define __FORCE_TRACE__
//#define __FORCE_DEBUG__
//#define __FORCE_INFO__
#define THIS_FILE "aisuppress\fn_alertGroup.sqf"
#include <core_macros.h>

TRACE_1("Start",_this);
TMFPROFILERSTART;

private ["_unit","_killer","_group","_units","_pos"];
DEFAULT_PARAM(_unit,0,objNull);
DEFAULT_PARAM(_killer,1,objNull);

if (!isNull _unit) then {
	_f_buller = _unit getVariable [QGVAR(FIRST_BULLET),time];
	_l_bullet = _unit getVariable [QGVAR(LAST_BULLET),time];
	// If the unit was killed fast enough it won't alert it's group
	if ((_l_bullet - _f_bullet) > 10) then {
		TRACE_1("Unit group alert",(_l_bullet - _f_bullet));
		_group = group _unit;
		_pos = position _unit;
		{ if (alive _x && {((_pos distance _x) <= GVAR(COVER_DISTANCE)) } &&  {(_unit getVariable [QGVAR(SEARCH_COVER),-1]) > 0}) then { [_x] call FUNC(findCover); }; true; } count (units _group);
	} else {
		TRACE_1("Unit died too fast",(_l_bullet - _f_bullet));
	};
};

TRACE("End");
TMFPROFILERSTOP;
